package com.yang.booking.service;

import com.yang.booking.dao.StoreMapper;
import com.yang.booking.pojo.Store;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
public class StoreService {

    @Autowired
    private StoreMapper storeMapper;

    public Map<String, Object> insertStore(String regionId, String name, String address, int schedulingCycle){

        Store store = new Store();
        store.setName(name);
        store.setAddress(address);
        store.setSchedulingCycle(schedulingCycle);
        store.setRegionId(regionId);
        store.setCreateAt(new Date());
        store.setUpdateAt(new Date());
        storeMapper.insert(store);

        Map<String, Object> msg = new HashMap<String, Object>();
        msg.put("massage", "插入成功");
        msg.put("code", 200);
        return msg;
    }

    public Map<String, Object> updateStoreSchedulingCycle(String storeId, String schedulingCycle){

        Store store = new Store();
        store.setId(storeId);
        store.setSchedulingCycle(Integer.parseInt(schedulingCycle));
        storeMapper.updateById(store);

        Map<String, Object> msg = new HashMap<String, Object>();
        msg.put("massage", "更新成功");
        msg.put("code", 200);
        return msg;
    }
}
